package ch04;

abstract class NoMethods{

}
class Extended1 extends NoMethods{
    public void f()
    {
        System.out.println("Extended1.f");
    }
}
abstract class WithMethods{
    abstract public void f();
}
class Extended2 extends WithMethods{
    public void f()
    {
        System.out.println("Extend2.f");
    }
}
public class Abstract{
    public static void test1(NoMethods nm)
    {
        // must downcast to access f();
        ((Extended1)nm).f();
    }
    public static void test2(WithMethods wm)
    {
        wm.f();
    }
    public static void main(String[] args)
    {
        //no downcast necessary
        NoMethods nm = new Extended1();
        test1(nm);
        WithMethods wm = new Extended2();
        test2(wm);  
    }
 }

